﻿$(document).on("pageInit", "#time-table-list", function (e, id, page) {
    loadList();

    function loadList() {
        $(page).find("#list").empty();
        $.getJSON("/TimeTable/GetAllTimeTableList", {}, function (response) {
            $.each(response, function (index, item) {
                var frame = $('<li>\
                    <a href="/timetable/courceList/'+ item.Id + '" class="item-link item-content">\
                        <div class="item-inner">\
                            <div class="item-title-row">\
                                <div class="item-title">' + item.TableName + '</div>\
                                <div class="item-after">' + item.CreateTime + '</div>\
                            </div>\
                            <div class="sub-title">班级：' + (item.ClazzName || '') + '</div>\
                            <div class="item-text">' + (item.Remark || '') + '</div>\
                        </div>\
                    </a>\
                </li>');
                $(page).find("#list").append(frame);
            });
        });
    }

    $(page).find("#menu-btn").on("click", function () {
        var buttons1 = [
        {
            text: '请选择',
            label: true
        },
        {
            text: '创建课表',
            bold: true,
            onClick: function () {
                $.router.load('/timetable/create', true);
            }
        }];

        var buttons2 = [
          {
              text: '取消',
              bg: 'danger'
          }
        ];
        var groups = [buttons1, buttons2];
        $.actions(groups);
    });
});